//package https;
//
//import com.highqi.security.admin.util.NullHostNameVerifier;
//import org.apache.http.HttpResponse;
//import org.apache.http.client.methods.HttpPost;
//import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
//import org.apache.http.entity.ContentType;
//import org.apache.http.entity.StringEntity;
//import org.apache.http.impl.client.CloseableHttpClient;
//import org.apache.http.impl.client.HttpClients;
//import org.apache.http.util.EntityUtils;
//
//import javax.net.ssl.SSLContext;
//import javax.net.ssl.TrustManager;
//import javax.net.ssl.TrustManagerFactory;
//import java.io.FileInputStream;
//import java.security.KeyStore;
//
//public class MyTest {
//
//    public static void main(String[] args) {
//        /*JSONObject jsonObject = new JSONObject();
//        String keystoreFile = "D:/data/test/sgm_auth.jks";
//        //String keystoreFile = "D:\\IdeaProjectsWorkspace\\dma-server\\ace-modules\\ace-admin\\src\\main\\resources\\server.keystore";
//        String keystorePass = "Pass1234";
//        try {
//            HttpsURLConnection.setDefaultHostnameVerifier(new NullHostNameVerifier());
//            TrustManager[] tm = {new MyX509TrustManager(keystoreFile, keystorePass)};//new MyX509TrustManager(keystoreFile, keystorePass)
//            SSLContext sslContext = SSLContext.getInstance("TLS");
//            sslContext.init(null, tm, new java.security.SecureRandom());
//            SSLSocketFactory ssf = sslContext.getSocketFactory();
//            String urlStr = "https://b2bqa.api.saic-gm.com/iapig/silk/sales-leads/saveLeadsGeneralBuickFromweb/lmc_ela/general/leads/buick/fromweb";
//            URL url = new URL(urlStr);
//            HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
//            con.setRequestProperty("Content-Type", "application/json;charset=UTF-8");
//            con.setRequestProperty("client_id", "63JtGxaT98SUsKR9H3F0un13G3BX2Hi3yMtXum2W6gjHs9ppvcZ4QOzF3h3");
//            con.setRequestProperty("APITag", "V1");
//            con.setRequestProperty("clientRequestId", System.currentTimeMillis()+"");
//            con.setSSLSocketFactory(ssf);
//            con.setRequestMethod("POST");
//            con.setDoInput(true);
//            con.setDoOutput(true);
////            con.connect();
//
//            jsonObject.put("appkey","");
//            jsonObject.put("channelid","60053");
//            jsonObject.put("realname","syy");
//            jsonObject.put("mobile","15236457894");
//
//            OutputStream out = con.getOutputStream();
//            out.write(jsonObject.toJSONString().getBytes("utf-8"));
//            out.flush();
//            out.close();
//            InputStreamReader in = new InputStreamReader(con.getInputStream(), "UTF-8");
//            BufferedReader bfreader = new BufferedReader(in);
//            String result = "";
//            String line = "";
//            while ((line = bfreader.readLine()) != null) {
//                result += line;
//            }
//        } catch (Exception e) {
//            e.printStackTrace();
//        }*/
//        try {
//
//        String keystoreFile = "D:/data/test/sgm_auth.jks";
//        String keystorePass = "Pass1234";
//
//        KeyStore keyStore = KeyStore.getInstance("JKS");
//
//
//        keyStore.load(new FileInputStream(keystoreFile),keystorePass.toCharArray());
//
//
//        TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance("SunX509");
//
//
//        trustManagerFactory.init(keyStore);
//
//        TrustManager[] tm = trustManagerFactory.getTrustManagers();
//
//
//        SSLContext sc = SSLContext.getInstance("TLSv1.2");
//
//
//        sc.init(null,  tm, null);
//
//        SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
//
//                sc,
//
//
//                new String[]{"TLSv1.2"},
//
//
//                new String[]{"TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384"},
//                new NullHostNameVerifier()
//
//        );
//
//
//        //CloseableHttpClient httpClient = HttpClients.custom().setSSLSocketFactory(sslsf).build();
//            HttpClient  httpClient = new DefaultHttpClient();
//        HttpPost httpPost = new HttpPost("https://b2bqa.api.saic-gm.com/iapig/silk/sales-leads/saveLeadsGeneralBuickFromweb/lmc_ela/general/leads/buick/fromweb");
//
//            httpPost.addHeader("Content-Type", "application/json;charset=UTF-8");
//            httpPost.addHeader("client_id", "63JtGxaT98SUsKR9H3F0un13G3BX2Hi3yMtXum2W6gjHs9ppvcZ4QOzF3h3");
//            httpPost.addHeader("APITag", "V1");
//            httpPost.addHeader("clientRequestId", System.currentTimeMillis()+"");
//            httpPost.setEntity(new StringEntity("{\n" +
//                    "    \"appkey\":\"eBuick_700\",\n" +
//                    "    \"channelid\":\"60053\",\n" +
//                    "    \"realname\":\"syy\",\n" +
//                    "    \"mobile\":\"15236457894\"\n" +
//                    "}", ContentType.create("application/json", "utf-8")));
//            System.out.println("request parameters" + EntityUtils.toString(httpPost.getEntity()));
//            System.out.println("httpPost:" + httpPost);
//            HttpResponse response = httpClient.execute(httpPost);
//            System.out.println(response);
//
//        }catch (Exception e){
//            e.printStackTrace();
//        }
//    }
//
//}
